package com.yanqu.road.server.pb;

import com.yanqu.road.entity.activity.hanghai.config.HangHaiConfig;
import com.yanqu.road.entity.activity.hanghai.config.HangHaiGoodsConfig;
import com.yanqu.road.entity.activity.hanghai.config.HangHaiPortConfig;
import com.yanqu.road.entity.activity.hanghai.config.HangHaiShipConfig;
import com.yanqu.road.pb.activity.HangHaiActivityProto;
import com.yanqu.road.server.manger.ServerLanguageMgr;

public class HangHaiPb {

    public static HangHaiActivityProto.HangHaiConfigMsg.Builder parseHangHaiConfigMsg(HangHaiConfig config, String language) {
        HangHaiActivityProto.HangHaiConfigMsg.Builder builder = HangHaiActivityProto.HangHaiConfigMsg.newBuilder();
        for (HangHaiPortConfig haiPortConfig : config.getPortConfigMap().values()) {
            builder.addPortList(parseHangHaiPortConfigMsg(haiPortConfig, language));
        }
        for (HangHaiGoodsConfig goodsConfig : config.getGoodsConfigMap().values()) {
            builder.addGoodsList(parseHangHaiGoodsConfigMsg(goodsConfig, language));
        }
        for (HangHaiShipConfig hangHaiShipConfig : config.getShipConfigList()) {
            builder.addShipList(parseHangHaiShipConfigMsg(hangHaiShipConfig, language));
        }
        return builder;
    }

    public static HangHaiActivityProto.HangHaiPortConfigMsg.Builder parseHangHaiPortConfigMsg(HangHaiPortConfig config, String language) {
        HangHaiActivityProto.HangHaiPortConfigMsg.Builder builder = HangHaiActivityProto.HangHaiPortConfigMsg.newBuilder();
        builder.setPortId(config.getPortId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(config.getDesc(), language));
        builder.setIcon(config.getIcon());
        builder.setPlaceCoordinate(config.getPlaceCoordinate());
        builder.setSpecGoodsId(config.getSpecGoodsId());
        return builder;
    }

    public static HangHaiActivityProto.HangHaiGoodsConfigMsg.Builder parseHangHaiGoodsConfigMsg(HangHaiGoodsConfig config, String language) {
        HangHaiActivityProto.HangHaiGoodsConfigMsg.Builder builder = HangHaiActivityProto.HangHaiGoodsConfigMsg.newBuilder();
        builder.setGoodsId(config.getGoodsId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setIcon(config.getIcon());
        builder.setBasePrice(config.getBasePrice());
        builder.setBaseNum(config.getBaseNum());
        return builder;
    }

    public static HangHaiActivityProto.HangHaiShipConfigMsg.Builder parseHangHaiShipConfigMsg(HangHaiShipConfig config, String language) {
        HangHaiActivityProto.HangHaiShipConfigMsg.Builder builder = HangHaiActivityProto.HangHaiShipConfigMsg.newBuilder();
        builder.setLevel(config.getLevel());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setIcon(config.getIcon());
        builder.setAddition(config.getAddition());
        builder.setUpgradeCost(config.getUpgradeCost());
        return builder;
    }

}
